package com.xjtu.se.homework.ops.faq.controller;

import com.xjtu.se.homework.common.Result;
import com.xjtu.se.homework.ops.faq.dto.FaqDto;
import com.xjtu.se.homework.ops.faq.dto.delDto;
import com.xjtu.se.homework.ops.faq.dto.pubDto;
import com.xjtu.se.homework.ops.faq.service.FaqService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/ops/faq")
public class FagAPI {
    @Resource
    private FaqService faqService;
    @PostMapping("/showAll")
    public Result queryFAQs(@RequestBody FaqDto dto){
        System.out.print(dto.toString());
        Map<String,Object> page =  faqService.getAllFaq(dto);
        return Result.success(page);
    }

    @PostMapping("/updateFaq")
    public Result faqUpd(@RequestBody FaqDto dto){

        return Result.success(faqService.faqUpd(dto));
    }

    @PostMapping("/addFaq")
    public Result faqAdd(@RequestBody FaqDto dto){
        Result Add = faqService.faqAdd(dto);
        return Add;
    }
    @PostMapping("/delFaq")
    public Result delFaq( @RequestBody delDto dto){
        Result Del =faqService.faqDel(dto);
        return Del;
    }
    @PostMapping("/pubFaq")
    public Result pubFaq( @RequestBody pubDto dto){
        Result Pub =faqService.faqPub(dto);
        return Pub;
    }
//    @PostMapping("/searchFaq")
//    public Result searchFAQs( @RequestBody SearchDto dto){
//        System.out.print(dto.toString());
//        Map<String,Object> page =  faqService.searchFaq(dto);
//        return Result.success(page);
//    }

}
